package com.emar.adx.yiqifa.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

/**
 * Created by xiaoliang on 2015/8/28 9:52.
 */
@Controller
public class RequestStatusController {

    private static final Logger logger = LoggerFactory.getLogger(RequestStatusController.class);

    @RequestMapping(value = "/step1")
    public String step1(Locale locale, Model model,HttpServletRequest request){

        logger.debug("step1...");
        return "test";
    }

    @RequestMapping(value = "/step2")
    public String step2(Locale locale, Model model,HttpServletRequest request){
        logger.debug("step2...");
        return "redirect:/http://www.baidu.com";
    }

    @RequestMapping(value = "/step3")
    public void step3(Locale locale, Model model,HttpServletRequest request,HttpServletResponse response){
        logger.debug("step3...");

        response.setStatus(200);
        response.setHeader("refresh", "0;URL=http://www.baidu.com");
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.addHeader("location", "http://www.baidu.com");
    }
}